import 'package:flutter/material.dart';
import 'package:x3_charts_core/chart_painter/multi_region_pie_chart_painter.dart';
import 'package:x3_charts_core/model/multi_region_pie_chart_model.dart';

///**
///* @author hrongyong
///* @date   2/21/21
///* @email hrongyong@gmail.com
///* Description:
///*/
class MultiRegionPieChartWidget extends StatefulWidget {
  final List<MultiRegionPieChartModel> chartList;
  final double titleFontSize;

  MultiRegionPieChartWidget({Key key, @required this.chartList, this.titleFontSize = 10});

  @override
  _MultiRegionPieChartWidgetState createState() => _MultiRegionPieChartWidgetState();
}

class _MultiRegionPieChartWidgetState extends State<MultiRegionPieChartWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: LayoutBuilder(
        builder: (BuildContext context, BoxConstraints constraints) {
          return CustomPaint(
            size: Size(constraints.maxWidth, constraints.maxHeight),
            painter: MultiRegionPieChartPainter(chartList: widget.chartList, titleFontSize: widget.titleFontSize),
          );
        },
      ),
    );
  }
}
